package com.gin.pixiv.interceptor

import com.gin.pixiv.enums.Language
import okhttp3.Interceptor
import okhttp3.Response

/**
 * @author bx002
 * @since 2024/2/18 12:01
 */
class LanguageInterceptor(private val language: Language) : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val request = chain.request()
        val url = request.url.newBuilder().addQueryParameter("lang", language.name).build()
        val newRequest = request.newBuilder().url(url).build()
        return chain.proceed(newRequest)
    }
}